package serviceset2.restTemplate

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.client.RestTemplate

class ServiceSet3Proxy {

    @Autowired
    RestTemplate restTemplate

    @HystrixCommand(fallbackMethod = "reliable")
    Map sampleApi3(String dependency) {
        def service_uri = "http://SERVICE-SET-3/sampleApi3?dependency={dependency}", args = [dependency: dependency]

        restTemplate.getForObject(service_uri, Map.class, args)
    }

    Map reliable(String dependency) {
        [provider: "sampleApi3@serviceSet3", dependency: dependency, state: "offline"]
    }
}
